package com.example.review;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class chapterFiveActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chapter_five);
        Button button=findViewById(R.id.toNetBroadcast);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(chapterFiveActivity.this,chapterFive2Activity.class);
                startActivity(intent);
            }
        });
        Button button1=findViewById(R.id.send_broadcast);
        button1.setOnClickListener(new View.OnClickListener() {


            /**
             * 发送有序广播  注意，还要在AndroidManifest.xml设定广播接收器的先后顺序
             */
            @Override
            public void onClick(View view) {
                Intent intent=new Intent("com.example.review.broadcast.MY_BROADCAST");
                //特别注意，安卓8及以上，一定要加上包的全路径，不然会没反应
                intent.setComponent(new ComponentName(getPackageName(),"com.example.review.broadcast.MyBroadcastReceiver"));
                //第二个是权限相关的，填null即可
                sendOrderedBroadcast(intent,null);
            }
            /**
             * 发送标准广播
             */
//            @Override
//            public void onClick(View view) {
//                Intent intent=new Intent("com.example.review.broadcast.MY_BROADCAST");
//                //特别注意，安卓8及以上，一定要加上包的全路径，不然会没反应
//                intent.setComponent(new ComponentName(getPackageName(),"com.example.review.broadcast.MyBroadcastReceiver"));
//                sendBroadcast(intent);
//            }
        });

        Button button2=findViewById(R.id.tof3);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(chapterFiveActivity.this,chapterFive3Activity.class);
                startActivity(intent);
            }
        });
    }
}